import copy
import random
class PokerBase:
    _poker = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'] * 4
    _poker += ['J', 'j']

    def __init__(self, need_shuffle=True):
        self.init(need_shuffle)

    def init(self, need_shuffle, shuffle_time=50):
        self.poker = copy.copy(self._poker)
        if need_shuffle:
            self.shuffle()

    def getOneCard(self):
        return self.poker.pop(0)

    def hasMore(self):
        return len(self.poker) > 0

    def shuffle(self, times=50):
        for i in xrange(times):
            a, b = random.sample(range(54), 2)
            t = self.poker[a]
            self.poker[a] = self.poker[b]
            self.poker[b] = t

    def __str__(self):
        return str(self.poker)

    def __repr__(self):
        return repr(self.poker)

